{include file="public/heder"/}
<header class="header" id="header">
    <a href="{:url('index')}" target=_self class="back">返回</a>
    <h1>登录</h1>
</header>
<!--header-end-->

<div class="container" id="container">

    <form method="post" class="login-form" action="{:url('login')}" id="login" autocomplete="off" onclick="return check()">
        <div class="registered">
            <div class="field">
                <input id="phoneNumber" type="text" name="phoneNumber" class="username" placeholder="请输入手机号" >
                <span id="msg" style="font-size: 12px;color:red"></span>
            </div>
            <div class="field">
                <input id="password" type="password" name="password" class="username" placeholder="请输入密码" >
                <span id="pwdmsg" style="font-size: 12px;color:red"></span>
            </div>
        </div>

        <div class="next-step">
            <button type="submit" onclick="login()" class="submit-btn">登录</button>
        </div>
    </form>
</div>
    <a href="{:url('register')}" style="font-size: 12px;color: #737373">没账号？免费注册</a>
    <button style="font-size: 12px;color: #737373" onclick="change()">更多</button>
<script>
    $('#phoneNumber').blur(function () {
        $.post("{:url('checkPhone')}", {'Phon': $('#phoneNumber').val(),'type':'login'}, function (data) {
            $('#msg').html(data);
        })
    })
    /*
    * 提交数据判断
    * */
    function check(){
        var phon = document.getElementById("phoneNumber");
        var pwd = document.getElementById("password");
        if(phon.value==''){
            $('#msg').html('手机号不能为空');
            return false;
        }else if(pwd.value==''){
            $('#pwdmsg').html('密码不能为空');
            return false
        }else{
            $('#msg').html('');
            $('#pwdmsg').html('');
        }

    }
    function login(){

        layer.open({
            type: 2
            ,content: '加载中'
        });
    }
    /*
    *
    * ajax提交页面的值
    * */
    function login() {
        $.ajax({
            url: "{:url('login')}",
            type: 'post',
            async:false,
            data: {'phoneNumber': $('#phoneNumber').val(), 'password': $('#password').val()},
            success: function (data) {
              if(data==1){
                  alert('该用户不存在')
              }else if(data==2)
              {
                  alert('密码错误');
              }else if(data==3) {

                }
            }


        })
    }
    /*
    *
    *
    * */
    function change() {
        layer.open({
            content: '请选择'
            , btn: ['微信登录', '忘记密码']
            , skin: 'footer'
            , yes: function (index) {
                layer.open({
                    type: 2
                    ,content: '登陆中'
                    ,time:5

                })
                window.location.href="{:url('loginOut')}"
            }
            ,no: function (index) {
                layer.open({
                    type: 2
                    ,content: '正在跳转页面'
                    ,time:5

                })
                window.location.href="{:url('register')}"
            }
        });

    }

</script>
<!--container-end-->
</body>
</html>